﻿using UnityEngine;
using System.Collections;

public class UICooldownKit : MonoBehaviour
{
    public TweenPosition tp;
    public float timer = 0;
    public UILabel timeText;

    public void Show(float time)
    {
        gameObject.SetActive(true);
        timer = time;
        tp.PlayForward();
    }

    public void Hide()
    {
        tp.PlayReverse();
        timer = 0;
    }

    void Update()
    {
        timer =timer - Time.deltaTime;
        timeText.text = (Mathf.Max(0,(int)timer)).ToString();
        if(timer < -2f)
        {
            gameObject.SetActive(false);
        }
    }
}
